
<style type="text/css">
.js_confirm_paid_row{cursor: pointer;}
.js_confirm_receive_row{cursor: pointer;}
.js_confirm_return_row{cursor: pointer;}
</style>

<div class="current_location">
    <ul>
        <li><a>当前位置：</a></li>
        <li><a>订单管理</a></li>
    </ul>
</div>

<div class="search_bar">
    <form id="search_form" onsubmit="return search_list();" action="<?php echo $this->get_url(array('page_num' => 1)); ?>" method="get">

        <ul class="search_field">
            <li>
                <label>id编号：</label>
                <input type="text" name="id" value="<?php echo $view_data['id']; ?>">
            </li>
            <li>
                <label>sn编号：</label>
                <input type="text" name="order_sn" value="<?php echo $view_data['order_sn']; ?>">
            </li>

            <li>
                <label>用户id：</label>
                <input type="text" name="member_id" value="<?php echo $view_data['member_id']; ?>">
            </li>


            <li>
				<label>状态：</label>
                <select name="status">

                    <option value="10" <?php if($view_data['status'] == 10): ?>selected="selected"<?php endif; ?>>全部</option>

                    <option value="0" <?php if($view_data['status'] == 0): ?>selected="selected"<?php endif; ?>>待付款</option>
                    <option value="1" <?php if($view_data['status'] == 1): ?>selected="selected"<?php endif; ?>>已付款</option>
                    <option value="2" <?php if($view_data['status'] == 2): ?>selected="selected"<?php endif; ?>>待收货</option>
                    <option value="3" <?php if($view_data['status'] == 3): ?>selected="selected"<?php endif; ?>>已收货</option>

                    <option value="-1" <?php if($view_data['status'] == -1): ?>selected="selected"<?php endif; ?>>已失效</option>
                    <option value="-2" <?php if($view_data['status'] == -2): ?>selected="selected"<?php endif; ?>>已退货</option>
                </select>
			</li>
        </ul>

        <div class="search_bar_sub_bar">
            <!-- <input type="hidden" name="page_num" value="1"/> -->
            <input class="input_submit" type="submit" value="搜索" />
        </div>
    </form>
</div>

<table class="list_table">
    <thead>
    <tr>
        <th width="60">id编号</th>
        <th>sn编号</th>
        <th width="80">金额</th>
        <th width="130">下单时间</th>
        <th width="60">用户id</th>
        <th width="50">状态</th>

        <th class="list_table_action">操作</th>
    </tr>
    </thead>
    <tbody>

    <?php $no = 1; ?>
    <?php foreach ($view_data['order_list'] as $order_info): ?>
        <tr>
            <td><?php echo $order_info['id']; ?></td>
            <td><?php echo $order_info['order_sn']; ?></td>
            <td><?php echo $order_info['order_total_price']; ?></td>
            <td><?php echo $order_info['create_time_date_time']; ?></td>

            <td><?php echo $order_info['member_id']; ?></td>

            <td><?php echo $order_info['status_desc']; ?></td>
            <td class="list_table_action">

                <a href="<?php echo $this->get_url(array('route' => 'pc_background_order_edit', 'id' => $order_info['id']), true); ?>">编辑</a><!-- | -->

                <!-- 在线支付，确认付款 -->
                <?php if($order_info['status'] == 0): ?>
                    <a class="js_confirm_paid_row" confirm_paid_url="<?php echo $this->get_url(array('route' => 'pc_background_order_confirm_paid', 'id' => $order_info['id']), true); ?>">确认付款</a>
                <?php endif; ?>

                <!-- 在线支付，确认收货 -->
                <?php if($order_info['status'] == 2): ?>
                <a class="js_confirm_receive_row" confirm_receive_url="<?php echo $this->get_url(array('route' => 'pc_background_order_confirm_receive', 'id' => $order_info['id']), true); ?>">确认收货</a>
                <?php endif; ?>

                <!-- 在线支付，确认退货 -->
                <?php if($order_info['status'] == 3): ?>
                <a class="js_confirm_return_row" confirm_return_url="<?php echo $this->get_url(array('route' => 'pc_background_order_confirm_return', 'id' => $order_info['id']), true); ?>">确认退货</a>
                <?php endif; ?>
            </td>
        </tr>

        <?php $no++; ?>
    <?php endforeach ?>

    </tbody>
</table>

<script type="text/javascript">

function search_list(){
    var id = $("#search_form input[name='id']").val();
    var order_sn = $("#search_form input[name='order_sn']").val();

    var member_id = $("#search_form input[name='member_id']").val();

    var status = $("#search_form select[name='status']").val();

    var url_params_json = <?php echo $this->get_url_params_json(array('page_num' => 1), true); ?>;
    url_params_json['page_num'] = 1;
    url_params_json['id'] = id;
    url_params_json['order_sn'] = order_sn;
    url_params_json['member_id'] = member_id;
    url_params_json['status'] = status;
    var url = wwy_get_url(url_params_json);

    window.top.location.replace(url);

    return false;
}


    //在线支付，确认付款
    $('.js_confirm_paid_row').click(function(){
        var confirm_paid_url = $(this).attr('confirm_paid_url');
        //alert(confirm_paid_url); return false;
        if(confirm('确认付款？')) {
            $.ajax({
                type: 'GET',
                url: confirm_paid_url,
                data: '',
                dataType: 'json',
                success: function (rdata) {
                    if (rdata.status <= 0) {
                        alert(rdata.message);
                    } else {
                        alert(rdata.message);
                        window.top.location.reload();
                    }

                    return false;
                }
            });
        }
    });

    //在线支付，确认收货
    $('.js_confirm_receive_row').click(function(){
        var confirm_receive_url = $(this).attr('confirm_receive_url');
        //alert(confirm_receive_url); return false;
        if(confirm('确认收货？')) {
            $.ajax({
                type: 'GET',
                url: confirm_receive_url,
                data: '',
                dataType: 'json',
                success: function (rdata) {
                    if (rdata.status <= 0) {
                        alert(rdata.message);
                    } else {
                        alert(rdata.message);
                        window.top.location.reload();
                    }

                    return false;
                }
            });
        }
    });


    //在线支付，确认退货
    $('.js_confirm_return_row').click(function(){
        var confirm_return_url = $(this).attr('confirm_return_url');
        //alert(confirm_return_url); return false;
        if(confirm('确认退货？')) {
            $.ajax({
                type: 'GET',
                url: confirm_return_url,
                data: '',
                dataType: 'json',
                success: function (rdata) {
                    if (rdata.status <= 0) {
                        alert(rdata.message);
                    } else {
                        alert(rdata.message);
                        window.top.location.reload();
                    }

                    return false;
                }
            });
        }
    });
</script>
